home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Programming / Dialog Director 0.6 / Examples / Documents+.as < prev    next >
Encoding:
Text File  |  1997-04-08  |  1.4 KB  |  48 lines  |  [TEXT/ToyS]

  1. property dNames : ["Done", "Add…", "Add…", "Add…", "Add…", "Add…", "Add…", "Add…", "Add…", "Add…", "Add…", "Add…"]
  2. property dDocs : [0, null, null, null, null, null, null, null, null, null, null, null]
  3. property dBounds : null
  4.  
  5. on run
  6.     dd install with floating
  7.     if dBounds = null then set dBounds to dd calc dialog bounds [405, 68]
  8.     dd make dialog {bounds:dBounds, contents:[¬
  9.         B(1), B(2), B(3), B(4), B(5), B(6), ¬
  10.         B(7), B(8), B(9), B(10), B(11), B(12) ¬
  11.         ], font:{name:"Helvetica", size:9}, style:sideways palette, name:"Documents"}
  12.     repeat
  13.         try
  14.             if DoAction(dd interact with user) then exit repeat
  15.         on error number err
  16.             if err ≠ -128 then exit repeat
  17.         end try
  18.     end repeat
  19.     set dBounds to last item of (dd get value of every item of dialog 1)
  20.     dd uninstall
  21. end run
  22.  
  23. on R(i)
  24.     set x to 5 + (i mod 4) * 100
  25.     set y to 5 + (i div 4) * 21
  26.     return [x, y, x + 95, y + 16]
  27. end R
  28.  
  29. on B(i)
  30.     return {class:push button, bounds:R(i - 1), name:item i of dNames}
  31. end B
  32.  
  33. on DoAction(i)
  34.     if i = 1 then return true
  35.     if item i of dDocs = null then
  36.         activate
  37.         set doc to choose file with prompt "Select a document:"
  38.         set AppleScript's text item delimiters to [":"]
  39.         set n to last text item of (doc as string)
  40.         set AppleScript's text item delimiters to ""
  41.         dd set name of item i of dialog 1 to n
  42.         set item i of dNames to n
  43.         set item i of dDocs to doc
  44.     else
  45.         tell application "Finder" to open item i of dDocs
  46.     end if
  47.     return false
  48. end DoAction